package com.atstudy.forword;

import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/1/30 14:53
 * @copyright: 博为峰
 */
public class ServletDemo01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(" ServletDemo01 ");

        RequestDispatcher dispatcher = req.getRequestDispatcher("/sd02");
        resp.setHeader("sd01", "sd01");
        //转发
        dispatcher.forward(req, resp);
        //包含
//        dispatcher.include(req, resp);
        PrintWriter pw = resp.getWriter();
        pw.write("sd01");
    }
}
